package com.pace.eps.controller;

import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.pace.eps.service.OrderPayService;
import com.pace.eps.service.EpsPaymentFeignService;
import javafx.beans.DefaultProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @auther dsl
 * @create 2020-02-20 0:05
 */
@RestController
@Slf4j
//@DefaultProperties(defaultFallback = "global_fallBack") // 全局服务降级
public class EpsOrderFeignController {
    @Resource
    private EpsPaymentFeignService paymentFeignService;

    @Resource
    private OrderPayService orderPayService;

    @GetMapping(value = "/consumer/payment/get/{id}")
    public String getPaymentById(@PathVariable("id") Long id) {
        return paymentFeignService.paymentzk();
    }

    @GetMapping(value = "/consumer/payment/feign/timeout")
    public String paymentFeignTimeout() {
        // OpenFeign客户端一般默认等待1秒钟
        return paymentFeignService.paymentFeignTimeout();
    }

    @GetMapping(value = "/consumer/payment/pay")
    public String pay() {
        // OpenFeign客户端一般默认等待1秒钟
        int a = 0;
        int b = 0;
//        a = a / b;
        return orderPayService.pay(a);
    }

    public String global_fallBack(){
        return " global_fallBack error";
    }
}
